package com.yehongyu.mytools.ui.swing;

//: ListCombo.java
//List boxes & Combo boxes
import java.awt.GridLayout;
import java.io.FileInputStream;
import java.util.List;

import javax.swing.JComboBox;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;

import org.jdom.Element;

public class ListCombo extends JPanel {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public ListCombo() {
		try {
			setLayout(new GridLayout(2, 1));
			JList list = new JList(ButtonGroups.ids);
			add(new JScrollPane(list));
			JComboBox combo = new JComboBox();
			org.jdom.input.SAXBuilder sb = new org.jdom.input.SAXBuilder();
			// 创建文档
			org.jdom.Document doc = sb.build(new FileInputStream(
					"d:\\assettypedata.xml"));
			// 获得这个文档得跟元素
			org.jdom.Element el = doc.getRootElement();
			// 获得这个跟元素，的所有子元素
			List<?> ls = el.getChildren();

			for (int i = 0; i < ls.size(); i++) {
				org.jdom.Element type = (Element) ls.get(i);
				org.jdom.Element el1 = type.getChild("codename");
				combo.addItem(el1.getValue());
			}
			add(combo);
		} catch (Exception e) {
			System.out.println(e.getMessage());

		}
	}

	public static void main(String args[]) {
		Show.inFrame(new ListCombo(), 200, 200);
	}
} // /:~
